package routes

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
	"mdblog/controllers"
)

func init() {
	admin := beego.NewNamespace(
		controllers.AdminApiPrefix,
		beego.NSCond(func(context *context.Context) bool {
			return true
		}),
		beego.NSRouter("/logout", &controllers.AdminApiController{}, "POST:Logout"),
		beego.NSRouter("/users", &controllers.AdminApiController{}, "POST:UserQuery"),
		beego.NSRouter("/user/create", &controllers.AdminApiController{}, "POST:AccountCreate"),
		beego.NSRouter("/user/changepass", &controllers.AdminApiController{}, "POST:ChangePassword"),

		// blog classify api
		beego.NSRouter("/classify/create", &controllers.BlogAdminApiController{}, "POST:ClassifyCreate"),
		beego.NSRouter("/classify/query", &controllers.BlogAdminApiController{}, "POST:ClassifyQuery"),
		beego.NSRouter("/classify/query/all", &controllers.BlogAdminApiController{}, "POST:ClassifyQueryAll"),
		beego.NSRouter("/targets/query", &controllers.BlogAdminApiController{}, "POST:TargetQuery"),
		beego.NSRouter("/targets/query/all", &controllers.BlogAdminApiController{}, "POST:TargetAll"),
		beego.NSRouter("/targets/create", &controllers.BlogAdminApiController{}, "POST:TargetCreate"),
		beego.NSRouter("/classify/targets/query", &controllers.BlogAdminApiController{}, "POST:ClassifyTargetQuery"),
		beego.NSRouter("/article/create", &controllers.BlogAdminApiController{}, "POST:ArticleCreate"),
		beego.NSRouter("/article/update", &controllers.BlogAdminApiController{}, "POST:ArticleUpdate"),
		beego.NSRouter("/article/query", &controllers.BlogAdminApiController{}, "POST:ArticleQuery"),
		beego.NSRouter("/article/delete/:id", &controllers.BlogAdminApiController{}, "POST:ArticleDelete"),
		beego.NSRouter("/config/query", &controllers.BlogAdminApiController{}, "POST:SiteConfigsPaginator"),
		beego.NSRouter("/config/create", &controllers.BlogAdminApiController{}, "POST:SiteConfigCreate"),
		beego.NSRouter("/config/update", &controllers.BlogAdminApiController{}, "POST:SiteConfigUpdate"),
		beego.NSRouter("/resource/query", &controllers.BlogAdminApiController{}, "POST:ResourcePaginator"),
		beego.NSRouter("/resource/upload", &controllers.BlogAdminApiController{}, "POST:ResourceUpload"),
		beego.NSRouter("/resource/remove", &controllers.BlogAdminApiController{}, "POST:ResourceRemove"),
		beego.NSRouter("/notice/query", &controllers.BlogAdminApiController{}, "POST:NoticePaginator"),
		beego.NSRouter("/notice/create", &controllers.BlogAdminApiController{}, "POST:NoticeCreate"),
		beego.NSRouter("/notice/update/:id", &controllers.BlogAdminApiController{}, "POST:NoticeUpdate"),
		beego.NSRouter("/carousel/query", &controllers.BlogAdminApiController{}, "POST:CarouselPaginator"),
		beego.NSRouter("/carousel/enable/update", &controllers.BlogAdminApiController{}, "POST:CarouselEnableUpdate"),
		beego.NSRouter("/carousel/remove", &controllers.BlogAdminApiController{}, "POST:CarouselRemove"),
		beego.NSRouter("/carousel/create", &controllers.BlogAdminApiController{}, "POST:CarouselCreate"),
	)
	beego.AddNamespace(admin)
}
